﻿namespace Mediator
{
    internal class ColleagueTextField : TextBox, IColleague
    {
        private IMediator mediator;
        public ColleagueTextField(string text, int columns)
        {
            this.Text = text;
        }

        public void SetColleagueEnabled(bool enabled)
        {
            this.Enabled = enabled;
            base.BackColor = Color.LightGray;
            if (this.Enabled)
            {
                base.BackColor = Color.White;
            }
        }

        public void SetMediator(IMediator mediator)
        {
            this.mediator = mediator;
        }

        protected override void OnTextChanged(EventArgs e)
        {
            mediator.ColleagueChanged();
            base.OnTextChanged(e);
        }
    }
}
